/*---------------------------------------
* Author:ZJ
* createDate:Tuesday, August 07, 2012
* Description:
*
------------------------------------------*/

#ifndef SERVSPACE_SERVER_HPP
#define SERVSPACE_SERVER_HPP

#include "StdAfx.h"
#include "connection_manager.hpp"
#include "connection.hpp"

namespace fly {

	namespace jld{

		namespace server {

			using namespace pool;
			class server:private boost::noncopyable
			{
			public:
				explicit server(handler* handler, const std::string& addr,const std::string& port);
				void run();
			private:
				void srv_ansy_accept();
				void handle_callback_accept(const boost::system::error_code& e);
				void clear();

				/// The signal_set is used to register for process termination notifications.
				boost::asio::signal_set signals_;

				/// Acceptor used to listen for incoming connections.
				boost::asio::ip::tcp::acceptor acceptor_;

				/// The connection manager which owns all live connections.
				connection_manager connection_manager_;

				//The handler for handling each module
				handler* handler_;

				/// The next connection to be accepted.
				connection_ptr new_connection_;
			};
		}
	}

}
#endif // SERVSPACE_SERVER_HPP